package com.loop.mapDemo;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class HashMapDemo {
    public static void main(String[] args) {
        HashMap<Integer, String> map = new HashMap<>();
        map.put(1,"hello1");
        map.put(2,"hello2");
        map.put(3,"hello3");
        map.put(4,"hello4");
        map.put(5,"hello5");
        System.out.println(map);
        System.out.println(map.remove(2));
        System.out.println(map.get(2));
        System.out.println(map.get(5));

        System.out.println(map.containsKey(3));
        System.out.println(map.isEmpty());
        //map.clear();
        map.size();

        Set<Integer> set = map.keySet();
        for (Integer i: set) {
            String s = map.get(i);
            System.out.println(i+"-"+s);
        }

        Set<Map.Entry<Integer, String>> entries = map.entrySet();
        for (Map.Entry<Integer, String> entry: entries) {
            Integer i = entry.getKey();
            String s = entry.getValue();
            System.out.println(i+"-"+s);
        }


    }
}
